<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()
const isScrolled = ref(false)

// 监听滚动事件
onMounted(() => {
  window.addEventListener('scroll', () => {
    isScrolled.value = window.scrollY > 50
  })
})

// 导航菜单
const navItems = [
  { name: '首页', path: '/' },
  { name: '产品', path: '/product' },
  { name: '价格', path: '/pricing' },
  { name: '文档', path: '/docs' },
  { name: '联系我们', path: '/contact' }
]

// 特性列表
const features = [
  {
    icon: '🚀',
    title: '智能对话',
    description: '基于先进的自然语言处理技术，提供流畅的对话体验'
  },
  {
    icon: '🎯',
    title: '精准理解',
    description: '深度理解用户意图，提供准确的回答和建议'
  },
  {
    icon: '🔄',
    title: '持续学习',
    description: '通过不断学习和优化，提供越来越好的服务'
  },
  {
    icon: '🔒',
    title: '安全可靠',
    description: '采用先进的安全技术，保护用户数据安全'
  }
]

// 产品优势
const advantages = [
  {
    title: '简单易用',
    description: '无需复杂配置，开箱即用',
    icon: '✨'
  },
  {
    title: '高度定制',
    description: '根据需求定制化开发，满足不同场景',
    icon: '⚙️'
  },
  {
    title: '快速部署',
    description: '支持多种部署方式，快速上线',
    icon: '🚀'
  }
]

// 跳转到聊天页面
const goToChat = () => {
  router.push('/chat')
}

// 跳转到文档页面
const goToDocs = () => {
  router.push('/docs')
}
</script>

<template>
  <div class="home">
    <!-- 导航栏 -->
    <nav :class="{ 'nav-scrolled': isScrolled }">
      <div class="nav-container">
        <div class="logo">
          <span class="logo-icon">🤖</span>
          <span>AI Assistant</span>
        </div>
        <div class="nav-links">
          <router-link v-for="item in navItems" :key="item.path" :to="item.path">
            {{ item.name }}
          </router-link>
        </div>
        <div class="nav-buttons">
          <button class="btn-login">登录</button>
          <button class="btn-register" @click="goToChat">立即开始</button>
        </div>
      </div>
    </nav>

    <!-- Hero 区域 -->
    <section class="hero">
      <div class="hero-content">
        <h1>智能 AI 助手</h1>
        <p>让 AI 成为您的得力助手，提升工作效率</p>
        <div class="hero-buttons">
          <button class="btn-primary" @click="goToChat">立即开始</button>
          <button class="btn-secondary" @click="goToDocs">了解更多</button>
        </div>
      </div>
      <div class="hero-image">
        <div class="hero-icon">🤖</div>
      </div>
    </section>

    <!-- 特性展示 -->
    <section class="features">
      <h2>核心特性</h2>
      <div class="features-grid">
        <div v-for="feature in features" :key="feature.title" class="feature-card">
          <div class="feature-icon">{{ feature.icon }}</div>
          <h3>{{ feature.title }}</h3>
          <p>{{ feature.description }}</p>
        </div>
      </div>
    </section>

    <!-- 产品优势 -->
    <section class="advantages">
      <h2>产品优势</h2>
      <div class="advantages-container">
        <div v-for="advantage in advantages" :key="advantage.title" class="advantage-item">
          <div class="advantage-content">
            <h3>{{ advantage.title }}</h3>
            <p>{{ advantage.description }}</p>
          </div>
          <div class="advantage-image">
            <div class="advantage-icon">{{ advantage.icon }}</div>
          </div>
        </div>
      </div>
    </section>

    <!-- 行动召唤 -->
    <section class="cta">
      <h2>准备好开始使用了吗？</h2>
      <p>立即开始，体验 AI 助手带来的便利</p>
      <button class="btn-primary" @click="goToChat">立即开始</button>
    </section>

    <!-- 页脚 -->
    <footer>
      <div class="footer-content">
        <div class="footer-section">
          <h4>关于我们</h4>
          <p>我们致力于为用户提供最优质的 AI 服务</p>
        </div>
        <div class="footer-section">
          <h4>快速链接</h4>
          <router-link to="/about">关于我们</router-link>
          <router-link to="/contact">联系我们</router-link>
          <router-link to="/privacy">隐私政策</router-link>
        </div>
        <div class="footer-section">
          <h4>联系方式</h4>
          <p>邮箱：2693176405@qq.com</p>
          <p>电话：18883799646</p>
        </div>
      </div>
      <div class="footer-bottom">
        <p>&copy; 2024 AI Assistant. All rights reserved.</p>
      </div>
    </footer>
  </div>
</template>

<style scoped>
.home {
  min-height: 100vh;
}

/* 导航栏样式 */
nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: transparent;
  transition: all 0.3s ease;
  padding: 1rem 0;
}

.nav-scrolled {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon {
  font-size: 2rem;
  margin-right: 0.5rem;
}

.logo span {
  font-size: 1.5rem;
  font-weight: bold;
  color: #333;
}

.nav-links {
  display: flex;
  gap: 2rem;
}

.nav-links a {
  color: #333;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
}

.nav-links a:hover {
  color: #007bff;
}

.nav-buttons {
  display: flex;
  gap: 1rem;
}

.btn-login, .btn-register {
  padding: 0.5rem 1.5rem;
  border-radius: 5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-login {
  background: transparent;
  border: 1px solid #007bff;
  color: #007bff;
}

.btn-register {
  background: #007bff;
  border: none;
  color: white;
}

.btn-login:hover {
  background: #007bff;
  color: white;
}

.btn-register:hover {
  background: #0056b3;
}

/* Hero 区域样式 */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.hero-content {
  max-width: 600px;
}

.hero h1 {
  font-size: 3.5rem;
  font-weight: bold;
  margin-bottom: 1.5rem;
  color: #333;
}

.hero p {
  font-size: 1.25rem;
  color: #666;
  margin-bottom: 2rem;
}

.hero-buttons {
  display: flex;
  gap: 1rem;
}

.btn-primary, .btn-secondary {
  padding: 1rem 2rem;
  border-radius: 5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary {
  background: #007bff;
  border: none;
  color: white;
}

.btn-secondary {
  background: transparent;
  border: 1px solid #007bff;
  color: #007bff;
}

.btn-primary:hover {
  background: #0056b3;
}

.btn-secondary:hover {
  background: #007bff;
  color: white;
}

.hero-image {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.hero-icon {
  font-size: 8rem;
  animation: float 6s ease-in-out infinite;
  text-align: center;
}

/* 特性展示样式 */
.features {
  padding: 5rem 2rem;
  background: white;
}

.features h2 {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 3rem;
  color: #333;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.feature-card {
  padding: 2rem;
  border-radius: 10px;
  background: white;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}

.feature-card:hover {
  transform: translateY(-5px);
}

.feature-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.feature-card h3 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: #333;
}

.feature-card p {
  color: #666;
  line-height: 1.6;
}

/* 产品优势样式 */
.advantages {
  padding: 5rem 2rem;
  background: #f8f9fa;
}

.advantages h2 {
  text-align: center;
  font-size: 2.5rem;
  margin-bottom: 3rem;
  color: #333;
}

.advantages-container {
  max-width: 1200px;
  margin: 0 auto;
}

.advantage-item {
  display: flex;
  align-items: center;
  gap: 4rem;
  margin-bottom: 4rem;
}

.advantage-item:nth-child(even) {
  flex-direction: row-reverse;
}

.advantage-content {
  flex: 1;
}

.advantage-content h3 {
  font-size: 2rem;
  margin-bottom: 1rem;
  color: #333;
}

.advantage-content p {
  color: #666;
  line-height: 1.6;
}

.advantage-image {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.advantage-icon {
  font-size: 4rem;
  text-align: center;
  margin-bottom: 1rem;
}

/* 行动召唤样式 */
.cta {
  padding: 5rem 2rem;
  text-align: center;
  background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
  color: white;
}

.cta h2 {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.cta p {
  font-size: 1.25rem;
  margin-bottom: 2rem;
  opacity: 0.9;
}

.cta .btn-primary {
  background: white;
  color: #007bff;
  font-size: 1.25rem;
  padding: 1rem 3rem;
}

.cta .btn-primary:hover {
  background: #f8f9fa;
}

/* 页脚样式 */
footer {
  background: #333;
  color: white;
  padding: 4rem 2rem 2rem;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 2rem;
}

.footer-section h4 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

.footer-section a {
  display: block;
  color: #ccc;
  text-decoration: none;
  margin-bottom: 0.5rem;
  transition: color 0.3s ease;
}

.footer-section a:hover {
  color: white;
}

.footer-bottom {
  text-align: center;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* 动画效果 */
@keyframes float {
  0% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-20px);
  }
  100% {
    transform: translateY(0px);
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .nav-links {
    display: none;
  }
  
  .hero {
    flex-direction: column;
    text-align: center;
    padding-top: 6rem;
  }
  
  .hero-content {
    margin-bottom: 3rem;
  }
  
  .hero-buttons {
    justify-content: center;
  }
  
  .advantage-item {
    flex-direction: column;
    text-align: center;
    gap: 2rem;
  }
  
  .advantage-item:nth-child(even) {
    flex-direction: column;
  }
  
  .advantage-image {
    max-width: 100%;
  }
}
</style>
